﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Text.RegularExpressions;

namespace NDepot.Validations
{
    public class ImageUrlAttribute : ValidationAttribute
    {
        public override bool IsValid(object value)
        {
            if (value == null)
            {
                return true;
            }
            
            string ImageUrl = (string)value;
            if (Regex.IsMatch(ImageUrl, @"\.(gif|jpg|png)$"))
                return true;
            else
                return false;
        }
    }
}